<template>
	<view class="app-container">
		<view class="header-bar-white search-wrap">
			<view class="input-box">
				<input v-model="queryParams.title" placeholder="请输入关键字"/>
				<uni-icons type="search" size="16" color="#DCDCDC"></uni-icons>
			</view>
			<view class="button-primary button" @click="query">查询</view>
		</view>
		<view v-if="list.length > 0">
			<view class="list">
				<view class="item">
					<view class="title">共 <text class="emphasize">{{total}}</text> 条</view>
				</view>
				<view class="item" v-for="item in list" @click="view(item)">
					<view class="title">{{item.title}}</view>
					<view class="summary two-lines">{{item.textContent}}</view>
					<view class="info">
						<view class="publisher">{{item.publisher?item.publisher:''}}</view>
						<view class="date">{{item.createTime.substring(0,10)}}</view>
					</view>
				</view>
			</view>
		</view>
		<view class="no-data" v-if="list.length == 0">
			<uni-icons custom-prefix="iconfont" type="icon-no-data" size="32" color="#999999"></uni-icons>
			<text class="text">暂无数据</text>
		</view>
	</view>
</template>

<script>
	import { ApiOrgan } from "@/api/system/index.js";
	import { ApiPolicy } from "@/api/information/index.js";
	
	export default {
		data() {
			return {
				user: {},
				queryParams: {
					manageDeptId: null,
					title: null,
					releaseStatus: '已发布',
					status: '1',
					byDesc: 'id',
					likeColumns: 'title',
					pageNum: 1,
					pageSize: 20
				},
				list: [],
				total: 0,
				pages: 0
			};
		},
		created() {
			this.user = this.$store.getUser();
			this.queryParams.manageDeptId = this.user.manageDeptId;
			this.getList();
		},
		onLoad(option) {
			this.queryParams.scheduleId = option.scheduleId;
		},		
		onReachBottom() {
			this.loadMore();
		},
		methods: {
		
			query(){
				this.list = [];
				this.queryParams.pageNum = 1;
				this.getList();
			},
			
			getList(){
				ApiPolicy.list(this.queryParams).then(res=>{
					this.list.push(...res.data.records);
					this.total = res.data.total;
					this.pages = res.data.pages;
				})
			},
			
			loadMore(){
				if(this.queryParams.pageNum >= this.pages)return;
				this.queryParams.pageNum = this.queryParams.pageNum+1;
				this.getList();
			},
			
			view(row){
				uni.navigateTo({
					url: '/pages/policy/info?id='+row.id
				})
			}
		}
	};
</script>

<style>
	.list{
		width: 100%;
		margin-top: 19upx;
	}
	.list .item{
		width: 100%;
		padding: 30upx;
		box-sizing: border-box;
		background-color: #ffffff;
		margin-top: 1upx;
	}
	.list .item .title{
		font-size: 16px;
		font-weight: bold;
	}
	.list .item .summary{
		margin-top: 15upx;
		height: ;
	}
	.list .item .info{
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-top: 15upx;
		color: #999999;
	}
	.two-lines {
	    display: -webkit-box;  /* 将元素设置为弹性布局 */
	    overflow: hidden; /* 隐藏超过指定高度的部分 */
	    text-overflow: ellipsis; /* 当内容被省略时显示省略号 */
	    line-height: 1.5em; /* 每行的高度 */
	    max-height: 3em; /* 最大高度（2行）*/
	    -webkit-line-clamp: 2; /* 控制显示的行数 */
	    -webkit-box-orient: vertical; /* 设置垂直方向展开 */
	}
	.search-wrap{
		width: 100%;
		display: flex;
		align-items: center;
	}
	.search-wrap .input-box{
		height: 43upx;
		display: flex;
		align-items: center;
		flex-grow: 2;
		border: 1upx solid #dcdcdc;
		border-radius: 30upx;
		padding: 10upx 10upx;
	}
	.search-wrap .input-box input{
		flex-grow: 2;
		margin-left: 10upx;
		text-indent: 10upx;
	}
	.search-wrap .button{
		height: 43upx;
		padding: 10upx 20upx;
		border-radius: 30upx;
		margin-left: 10upx;
	}
	.emphasize{
		color: #FF7B00;
	}
</style>
